package com.controller;

import com.entity.Friend;
import com.entity.FriendMessage;
import com.github.pagehelper.PageInfo;
import com.service.FriendMessageService;
import com.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class FriendMessageController {
    @Autowired
    private FriendMessageService friendMessageService;

    @GetMapping("/friendMessage")
    public ResponseVO getByFriendId(Integer userId,Integer friendId){
        List<FriendMessage> result = friendMessageService.getByFriendId(userId,friendId);
        return new ResponseVO("200",null,result);
    }

    @GetMapping("/friendMessage/all")
    public ResponseVO getAll(Integer pageNum,Integer pageSize,Integer userId,Integer friendId){
        List<FriendMessage> result = friendMessageService.getAll(pageNum, pageSize, userId, friendId);
        PageInfo pageInfo = new PageInfo(result);
        return new ResponseVO("200",null,pageInfo);
    }

    @PutMapping("/friendMessage")
    public ResponseVO editBackById(Integer id){
        friendMessageService.editBackById(id);
        return new ResponseVO("200","撤回成功",null);
    }
}
